package bold.redisson;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

import java.util.concurrent.TimeUnit;

public class SpringRedis {
    public static void main(String[] args) {
        ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:spring-config.xml");

        RedisTemplate redisTemplate = factory.getBean(RedisTemplate.class);

        ValueOperations<String,Integer> valueOperations = redisTemplate.opsForValue();
        Long lkl1 = valueOperations.increment("lllll", 1);
        Long lkl2 = valueOperations.increment("lllll", 1);
        System.out.println(lkl2);
        redisTemplate.expire("lllll", 1, TimeUnit.HOURS);

        redisTemplate.opsForValue().setIfAbsent("", "");

    }
}
